<template>
  <div class="loading-container">
    <div class="loading-container">
      <el-icon class="loading-icon">
        <Loading />
      </el-icon>
      <p class="loading-text">
        报告生成中，请耐心等待<span class="dots">...</span>
      </p>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
// import { ElLoadingSpinner } from 'element-plus';

// 加载点动画
const loadingDots = ref('');
let dotsInterval;


onMounted(() => {
  // 初始化省略号动画（3个点循环显示）
  dotsInterval = setInterval(() => {
    const dots = document.querySelector('.dots');
    if (dots) {
      const current = dots.textContent;
      dots.textContent = current.length < 3 ? current + '.' : '';
    }
  }, 500); // 每500ms更新一次
});

onUnmounted(() => {
  // 清除定时器
  clearInterval(dotsInterval);
});
</script>

<style scoped>
/* 动态加载提示样式 */
.loading-container {
  text-align: center;
  padding: 40px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-icon {
  font-size: 40px;
  color: #409eff;
  /* 蓝色加载图标 */
  animation: spin 1.5s linear infinite;
  /* 图标旋转动画 */
}

.loading-text {
  font-size: 16px;
  color: #666;
}

/* 省略号动画容器 */
.dots {
  display: inline-block;
  width: 24px;
  /* 固定宽度，避免文字跳动 */
  text-align: left;
}

/* 加载图标旋转动画 */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}
</style>
